package com.chu.advice;

import org.aspectj.lang.JoinPoint;

import java.util.Arrays;

public class LoggerAdvice {

    public void writeLog(){
        System.out.println("前置增强.................");
    }
    //获得当前被增强的方法的信息
    public void afterReturning(JoinPoint joinPoint,Object result){
        //全部参数
        Object[] args = joinPoint.getArgs();
        //目标类的实例
        Object target = joinPoint.getTarget();
        //方法名
        String name = joinPoint.getSignature().getName();

        System.out.println("后置增强.................");
        System.out.println("方法参数................."+ Arrays.toString(args));
        System.out.println("被代理类................."+target);
        System.out.println("被增强方法................."+name);
        System.out.println("方法返回值................."+result);
    }
    public void after(){
        System.out.println("最终增强。。。。。。。。。。");
    }
}
